-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix null-ref in AliasSymbol.Equals
#59649
Conversation
@@ -253,7 +254,7 @@ public override bool Equals(Symbol? obj, TypeCompareKind compareKind) | |||
|
|||
return (object?)other != null && | |||
Equals(this.Locations.FirstOrDefault(), other.Locations.FirstOrDefault()) && | |||
this.ContainingAssembly.Equals(other.ContainingAssembly, compareKind); | |||
Equals(this.ContainingSymbol, other.ContainingSymbol, compareKind); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think we want the symbols not to be equal in the scenario with two compilations. But if we use ContainingAssembly
(which is null) then they would be equal.
If we use ContainingSymbol
(which is the global namespace) then they are not equal, which I think is correct.
We could only compare using ContainingSymbol
when ContainingAssembly
is null, if that seems better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this a change in behavior then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous behavior for that scenario was a crash (null-ref). I don't think there's a change of behavior aside from that.
Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (commit 2)
@dotnet/roslyn-compiler for second review. Thanks |
AliasSymbol.Equals
Fixes #58999
FYI @AlekseyTs